package com.engine.core.interceptor;

/**
 * 递归command。可以反复执行
 * @param <T>
 * @param <R>
 */
public interface WhileCommand<T,R extends CommandContext,K>  {

    /**
     * 判断循环是否继续
     * @param lastResponse
     * @param commandContext
     * @param vars
     * @return
     * @throws Exception
     */
    boolean judgement(T lastResponse, R commandContext,K vars) throws Exception;

    /**
     * 执行循环体
     * @param lastResponse
     * @param commandContext
     * @param vars
     * @return
     * @throws Exception
     */
    T action(T lastResponse,R commandContext,K vars) throws Exception;;

    /**
     * 初始化循环变量
     * @param lastResponse
     * @param commandContext
     * @return
     */
    K initVar(T lastResponse, R commandContext);
}
